<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.camunda.bpm.webapp</groupId>
    <artifactId>camunda-webapp-root</artifactId>
    <version>7.20.0-SNAPSHOT</version>
    <relativePath>../</relativePath>
  </parent>

  <artifactId>camunda-webapp</artifactId>
  <packaging>war</packaging>
  <name>Camunda Platform - Webapp - Assembly</name>
  <inceptionYear>2014</inceptionYear>

  <properties>
    <java.resources.override>src/main/runtime/default/resources</java.resources.override>
    <properties.override>src/main/runtime/default/config.properties</properties.override>

    <!-- generate a bom of compile time dependencies for the license book.
    Note: Every compile time dependency will end up in the license book. Please
    declare only dependencies that are actually needed -->
    <skip-third-party-bom>false</skip-third-party-bom>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-engine-rest-core</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-engine-rest</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!-- jee spec -->
    <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-6.0</artifactId>
      <type>pom</type>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.spec.javax.ws.rs</groupId>
          <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.jboss.spec.javax.ws.rs</groupId>
      <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- rest api -->
    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-rest-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${version.spring.framework}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${version.spring.framework}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine-rest-core</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <classifier>tests</classifier>
    </dependency>
  </dependencies>

  <build>
    <finalName>camunda-webapp</finalName>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>${java.resources.override}</directory>
        <filtering>true</filtering>
      </resource>
    </resources>

    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
      </testResource>
    </testResources>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <failIfNoTests>false</failIfNoTests>
          <trimStackTrace>false</trimStackTrace>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>1.14</version>
        <configuration>
          <excludedScopes>test</excludedScopes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <configuration>
              <target>
                <mkdir dir="${project.basedir}/target/webapp" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources-assembly</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/webapp</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../frontend/target/webapp</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>sonatype-oss-release</id>
      <properties>
        <!-- skip building the frontend-sources zip artifact
        when releasing the community edition (alpha/minor releases) -->
        <skip-zip-frontend-sources>true</skip-zip-frontend-sources>
      </properties>
    </profile>

    <profile>
      <id>os</id>
      <activation>
        <os>
          <family>Windows</family>
        </os>
      </activation>
      <properties>
        <exec.shell>cmd</exec.shell>
        <exec.arg>/c</exec.arg>
      </properties>
    </profile>

    <profile>
      <id>develop</id>
      <dependencies>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jaxrs</artifactId>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.spec.javax.ws.rs</groupId>
          <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
        </dependency>
        <dependency>
          <groupId>org.camunda.bpm</groupId>
          <artifactId>camunda-engine</artifactId>
        </dependency>
        <dependency>
          <groupId>org.camunda.bpm</groupId>
          <artifactId>camunda-engine-plugin-spin</artifactId>
        </dependency>
        <dependency>
          <groupId>org.camunda.spin</groupId>
          <artifactId>camunda-spin-dataformat-json-jackson</artifactId>
        </dependency>
        <dependency>
          <groupId>org.camunda.spin</groupId>
          <artifactId>camunda-spin-dataformat-xml-dom</artifactId>
        </dependency>
        <dependency>
          <groupId>org.camunda.bpm</groupId>
          <artifactId>camunda-engine-plugin-connect</artifactId>
        </dependency>
        <dependency>
          <groupId>org.camunda.bpm.identity</groupId>
          <artifactId>camunda-identity-ldap</artifactId>
        </dependency>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
        </dependency>
        <dependency>
          <groupId>com.fasterxml.uuid</groupId>
          <artifactId>java-uuid-generator</artifactId>
        </dependency>
        <dependency>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
          <version>${version.xml.jaxb-impl}</version>
        </dependency>
        <dependency>
          <groupId>org.graalvm.js</groupId>
          <artifactId>js</artifactId>
        </dependency>
        <dependency>
          <groupId>org.graalvm.js</groupId>
          <artifactId>js-scriptengine</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <configuration>
                  <tasks>
                    <mkdir dir="${project.basedir}/target/webapp" />
                    <mkdir dir="${project.basedir}/target/camunda-welcome" />
                  </tasks>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
              <webAppConfig>
                <contextPath>/camunda</contextPath>
                <defaultsDescriptor>${project.basedir}/src/main/runtime/develop/jetty/webdefault.xml</defaultsDescriptor>
                <resourceBases>
                  <resourceBase>${project.basedir}/target/webapp</resourceBase>
                  <resourceBase>${project.basedir}/src/main/webapp</resourceBase>
                </resourceBases>
              </webAppConfig>
              <contextHandlers>
                <contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
                  <war>${project.basedir}/target/camunda-welcome/</war>
                  <contextPath>/camunda-welcome</contextPath>
                </contextHandler>
              </contextHandlers>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-sources</id>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/main/runtime/develop/java</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-resources</id>
                <goals>
                  <goal>add-resource</goal>
                </goals>
                <configuration>
                  <resources>
                    <resource>
                      <directory>src/main/runtime/develop/resources</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <java.resources.override>src/main/runtime/develop/resources</java.resources.override>
      </properties>
    </profile>

    <profile>
      <id>mariadb</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludedGroups>org.camunda.bpm.cockpit.plugin.base.SlowMariaDbTest</excludedGroups>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>h2</id>
      <properties>
        <project.parent.basedir>./</project.parent.basedir>
      </properties>
    </profile>

    <profile>
      <id>dev-e2e</id>
      <dependencies>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jaxrs</artifactId>
          <scope>runtime</scope>
        </dependency>
        <!-- We need to override the "provided" scope
          from the main dependency declaration here or
          else the dependency will not be available in Jetty
          (see also Jetty plugin config option useProvidedScope) -->
        <dependency>
          <groupId>org.jboss.spec.javax.ws.rs</groupId>
          <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <configuration>
                  <tasks>
                    <mkdir dir="${project.basedir}/target/webapp" />
                    <mkdir dir="${project.basedir}/target/camunda-welcome" />
                  </tasks>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${version.jetty}</version>
            <configuration>
              <webAppConfig>
                <contextPath>/camunda</contextPath>
                <defaultsDescriptor>${project.basedir}/src/main/runtime/test/jetty/webdefault.xml</defaultsDescriptor>
                <resourceBases>
                  <resourceBase>${project.basedir}/target/webapp</resourceBase>
                  <resourceBase>${project.basedir}/src/main/webapp</resourceBase>
                </resourceBases>
              </webAppConfig>
              <contextHandlers>
                <contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
                  <war>${basedir}/target/engine-rest.war</war>
                  <contextPath>/engine-rest</contextPath>
                </contextHandler>
                <contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
                  <war>${project.basedir}/target/camunda-welcome/</war>
                  <contextPath>/camunda-welcome</contextPath>
                </contextHandler>
              </contextHandlers>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.camunda.bpm</groupId>
                <artifactId>camunda-engine</artifactId>
                <version>${project.version}</version>
              </dependency>
              <dependency>
                <groupId>org.camunda.bpm.identity</groupId>
                <artifactId>camunda-identity-ldap</artifactId>
                <version>${project.version}</version>
              </dependency>
              <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
                <version>${version.slf4j}</version>
              </dependency>
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${version.h2}</version>
              </dependency>
              <dependency>
                <groupId>com.fasterxml.uuid</groupId>
                <artifactId>java-uuid-generator</artifactId>
                <version>${version.uuid-generator}</version>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-sources</id>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/main/runtime/test/java</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-resources</id>
                <goals>
                  <goal>add-resource</goal>
                </goals>
                <configuration>
                  <resources>
                    <resource>
                      <directory>src/main/runtime/test/resources</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.10</version>
            <executions>
              <execution>
                <id>copy</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.camunda.bpm</groupId>
                      <artifactId>camunda-engine-rest</artifactId>
                      <version>${project.version}</version>
                      <type>war</type>
                      <classifier>tomcat</classifier>
                      <overWrite>true</overWrite>
                      <outputDirectory>${project.build.directory}/</outputDirectory>
                      <destFileName>engine-rest.war</destFileName>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <java.resources.override>src/main/runtime/test/resources</java.resources.override>
      </properties>
    </profile>

    <!-- database QA profiles -->
    <profile>
      <id>database</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>database-test-drop-schema-before-test</id>
                <phase>process-test-classes</phase>
                <goals>
                  <goal>java</goal>
                </goals>
              </execution>
              <execution>
                <id>database-test-drop-schema-after-test</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>java</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <mainClass>org.camunda.bpm.engine.impl.db.DbSchemaDrop</mainClass>
              <classpathScope>test</classpathScope>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- profile for running cockpit testsuite with database table prefix -->
    <profile>
      <id>db-table-prefix</id>
      <!-- imports the DbSchemaPrefixTestHelper class -->
      <dependencies>
        <dependency>
          <groupId>org.camunda.bpm</groupId>
          <artifactId>camunda-engine</artifactId>
          <version>${project.version}</version>
          <scope>test</scope>
          <classifier>tests</classifier>
        </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>database-test-create-schema</id>
                <phase>process-test-classes</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <copy file="target/test-classes/camunda.cfg.prefix.xml" tofile="target/test-classes/camunda.cfg.xml" overwrite="true" />
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>cfgAuthorizationCheckRevokesAlways</id>
      <properties>
        <authorizationCheckRevokes>always</authorizationCheckRevokes>
      </properties>
    </profile>

    <!--  check history audit -->
    <profile>
      <id>cfghistoryaudit</id>
      <properties>
        <history.level>audit</history.level>
      </properties>
    </profile>

    <!--  check history activity -->
    <profile>
      <id>cfghistoryactivity</id>
      <properties>
        <history.level>activity</history.level>
      </properties>
    </profile>

    <!--  check history none -->
    <profile>
      <id>cfghistorynone</id>
      <properties>
        <history.level>none</history.level>
      </properties>
    </profile>

    <profile>
      <id>cfgJdbcBatchProcessingOff</id>
      <properties>
        <jdbcBatchProcessing>false</jdbcBatchProcessing>
      </properties>
    </profile>

    <profile>
      <id>license-header-check</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

</project>
